package com.lesso.yjy.sunflower.domain.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.lesso.yjy.sunflower.domain.repository.EmployeeDeviceRepository;
import com.lesso.yjy.sunflower.infra.assembler.EmployeeDeviceAssembler;
import com.lesso.yjy.sunflower.model.EmployeeDevice;
import com.lesso.yjy.sunflower.pojo.dto.EmployeeDeviceDTO;
import com.lesso.yjy.sunflower.pojo.dto.EmployeeDeviceQueryDTO;
import com.lesso.yjy.sunflower.pojo.vo.EmployeeDeviceVO;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class EmployeeDeviceDomainService {
    private final EmployeeDeviceRepository employeeDeviceRepository;

    public EmployeeDeviceDomainService(EmployeeDeviceRepository employeeDeviceRepository){
        this.employeeDeviceRepository = employeeDeviceRepository;
    }

    public Long save(EmployeeDeviceDTO dto){
        return employeeDeviceRepository.save(EmployeeDeviceAssembler.INSTANCE.dtoToEntity(dto));
    }

    public Page<EmployeeDeviceVO> page(EmployeeDeviceQueryDTO dto){
        return employeeDeviceRepository.getPageList(dto);
    }

    public Page<EmployeeDeviceVO> customPage(EmployeeDeviceQueryDTO dto){
        return employeeDeviceRepository.getCustomPageList(dto);
    }
    public void deleteById(Long id){
        employeeDeviceRepository.deleteById(id);
    }

    public void update(EmployeeDeviceDTO dto){
        employeeDeviceRepository.updateById(dto);
    }
}
